package online.longzipeng.mywebdemo.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import online.longzipeng.mywebdemo.entity.User;
import online.longzipeng.mywebdemo.pojo.vo.UserVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * @author lzp
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

	@Select("SELECT nick_name,age,sex FROM user ${ew.customSqlSegment}")
	List<UserVo> selectVos(@Param(Constants.WRAPPER) Wrapper<User> wq);

	@Select("SELECT * FROM user ${ew.customSqlSegment}")
	Page<User> page(Page<User> page, @Param(Constants.WRAPPER) Wrapper<User> wq);

	/**
	 * insert 的方式进行批量修改
	 *
	 * @param users
	 */
	void updateBatchByInsert(@Param("users") List<User> users);

	/**
	 * when case 的方式进行批量修改
	 */
	void updateBatchByWhenCase(@Param("users") List<User> users);


	/**
	 * 批量插入
	 */
	void batchInsert(@Param("users") List<User> users);

	/**
	 * 通过id查询基础用户对象
	 */
	UserVo getUserVoById(@Param("id") Integer id);

	/**
	 * 查询uids关联的基础用户数据
	 */
	List<UserVo> listUserVoByIds(@Param("uids") Set<Integer> uids);
}

